#include<iostream>
#include<string>
#include<memory>
#include<unordered_map>
using namespace std;

struct JceStructBase
{
public:
	int age;
	string name;
	JceStructBase(int age,string name):age(age),name(name) {}
	virtual ~JceStructBase() {}
};
int func1(unordered_map<int, shared_ptr<string>> sp)
{
	for(auto pair : sp)
	{
		pair.second = make_shared<string>("null");
	}
	unordered_map<int, shared_ptr<string>>::iterator it;
	for(it = sp.begin(); it != sp.end(); ++it)
	{
		cout<<"key="<<it->first<<" value="<<*(it->second)<<endl;
	}
	return 0;
}
int func2(unordered_map<int, shared_ptr<JceStructBase>> sp)
{
	unordered_map<int, shared_ptr<JceStructBase>>::iterator it;
	for(it = sp.begin(); it != sp.end(); ++it)
	{
		cout<<"key="<<it->first<<" value="<<it->second->name<<endl;
	}
	return 0;
}
int main()
{
	unordered_map<int, shared_ptr<string>> key2Jce;

	shared_ptr<string> pStra = make_shared<string>("tom");
	shared_ptr<string> pStrb = make_shared<string>("jerry");

	key2Jce.insert(pair<int, shared_ptr<string>>(0,pStra));
	key2Jce.insert(pair<int, shared_ptr<string>>(1,pStrb));

	func1(key2Jce);

	unordered_map<int, shared_ptr<JceStructBase>> key2JceSPtr;

	shared_ptr<JceStructBase> pJcea = make_shared<JceStructBase>(2,"lisa");
	shared_ptr<JceStructBase> pJceb = make_shared<JceStructBase>(3,"jean");

	key2JceSPtr.insert(pair<int, shared_ptr<JceStructBase>>(2,pJcea));
	key2JceSPtr.insert(pair<int, shared_ptr<JceStructBase>>(3,pJceb));

	func2(key2JceSPtr);
	return 0;
}